import request from '@/utils/request'

// 资产组

// 删除资产组信息
export function delAssetGroup (params) {
  var data = fromData(params)
  return request({
    url: '/asset_group/del_asset_group',
    method: 'post',
    data
  })
}

// 增加资产组信息
export function addAssetGroup (params) {
  var data = fromData(params)
  return request({
    url: '/asset_group/addAssetGroup',
    method: 'post',
    data
  })
}

// 编辑资产组信息
export function editAssetGroup (params) {
  var data = fromData(params)
  return request({
    url: '/asset_group/editAssetGroup',
    method: 'post',
    data
  })
}

// 获取资产组信息
export function getAssetGroupInfo (params) {
  var data = fromData(params)
  return request({
    url: '/asset_group/getAssetGroupInfo',
    method: 'post',
    data
  })
}

// 获取资产组列表
export function getAssetGroupArray (params) {
  var data = fromData(params)
  return request({
    url: '/asset_group/getAssetGroupArray',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
